<html>
<head>
<title>KAR Admin - Confirm Add/Edit an Event</title>
</head>
<body>

<?php

include($_SERVER['DOCUMENT_ROOT'] ."/includes/db.php");
				// Connect to the database server
dbConnect('kar_web1');   	// Use function in db.php to connect

		if ($a_ampm =='pm' && $a_hour <>12) 
			{ 
			   $a_hour=$a_hour+12;
			}

		if ($d_ampm=='pm' && $d_hour <>12) 
			{
			  $d_hour = $d_hour+12;
			}


$arrayBegin = array($a_hour, $a_minute, '00');
$BeginTimeFormatted = implode(":", $arrayBegin);
$arrayEnd = array($d_hour, $d_minute, '00');
$EndTimeFormatted = implode(":", $arrayEnd);
$arrayDate = array($eventyear, $eventmonth, $eventday);
$DateFormatted = implode("-",$arrayDate);
  

if (isset($update)):
	$sql="UPDATE events SET
		eventName = '$eventName',
		eventDate = '$DateFormatted',
		eventBeginTime = '$BeginTimeFormatted',
		eventEndTime='$EndTimeFormatted'
		WHERE eventID='$eventID'";
   else:
	$sql ="INSERT INTO events SET
		eventName = '$eventName',
		eventDate = '$DateFormatted',
		eventBeginTime = '$BeginTimeFormatted',
		eventEndTime='$EndTimeFormatted'";
   endif;

if (@mysql_query($sql)) {
	if (isset($update)) {
		echo("<p>Updated event info in the EVENTS table.  </p>");
		} else {
		echo("<p>Added event to the EVENTS table.  </p>");
		}
	$okayToProceed = 1;
      } else {
	echo("<p>Error adding first set of data: " . mysql_error() . "</p>");
      }
    echo("<p>Back to  <a href='../admin.php'>Admin Page</a></p>");
?>




</body>
</html>